package com.store.app.utils;

/**
 * String utils.
 * Created by Liam on 2018/4/25.
 */
public final class StringUtils {

    private StringUtils() {
        // prevent from being instantiating.
    }

    public static boolean isEmpty(String value) {
        return value == null || value.length() == 0;
    }

    public static boolean isBlank(String value) {
        return isEmpty(value) || value.trim().length() == 0;
    }

    /**
     * 防止接收到 "null" 字符串的情况。
     */
    public static boolean isEmptyOrNull(String value) {
        return isEmpty(value) || value.equalsIgnoreCase("null");
    }

    /**
     * @return Empty string if the specified value is null.
     */
    public static String nullToEmpty(String value) {
        return value == null ? "" : value;
    }

}
